package view.mediator.weapon.long_sword
{
	import flash.system.System;
	
	import model.weapon.WeaponModel;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import view.component.weapon.long_sword.LongSwordView;
	import view.event.weapon.long_sword.LongSwordViewEvent;
	
	
	/**
	 * LongSwordView界面中介
	 * @author £iang
	 * 
	 */	
	public class LongSwordViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** LongSwordView界面 */
		[Inject]
		public var longSwordView:LongSwordView;
		/** weaponModel */
		[Inject]
		public var weaponModel:WeaponModel;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			longSwordView.otherView.setText( weaponModel.weaponOtherInfoData["long_sword"] );
			addContextListener( LongSwordViewEvent.CHANGE_PAGE, changePageHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理请求滚动条容器翻页时派发的消息 
		 * @param event 请求滚动条容器翻页时派发的消息 
		 * 
		 */		
		protected function changePageHandler( event:LongSwordViewEvent ):void
		{
			longSwordView.changeSCPageIndex( event.newPage );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeContextListener( LongSwordViewEvent.CHANGE_PAGE, changePageHandler );
			longSwordView.mainSC.removeChild( longSwordView.listView, true );
			longSwordView.listView = null;
			longSwordView.mainSC.removeChild( longSwordView.detailView, true );
			longSwordView.detailView = null;
			longSwordView.mainSC.removeChild( longSwordView.searchView, true );
			longSwordView.searchView = null;
			longSwordView.mainSC.removeChild( longSwordView.motionView, true );
			longSwordView.motionView = null;
			System.gc();
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LongSwordViewMediator()
		{
			super();
		}
	}
}